﻿@{
    Layout = "~/Modules/Common/Views/Shared/_Layout.cshtml";
    Easy.Web.CMS.Layout.LayoutEntity layOut = ViewData[Easy.Web.CMS.Layout.LayoutEntity.LayoutKey] as Easy.Web.CMS.Layout.LayoutEntity;
}
@{
    bool zoneStart = false;
    foreach (var item in layOut.Html)
    {
        if (item.Html == Easy.Web.CMS.Zone.ZoneEntity.ZoneTag)
        {
            zoneStart = true;
            continue;
        }
        if (zoneStart)
        {
            if (layOut.ZoneWidgets.ContainsKey(item.Html))
            {
                foreach (var widgetPart in layOut.ZoneWidgets[item.Html].OrderBy(m => m.Widget.Position).ThenBy(m => m.Widget.WidgetName))
                {
                    <div class="@widgetPart.Widget.StyleClass">
                        @Html.Partial(widgetPart.Widget.PartialView, widgetPart.ViewModel)
                    </div>
                }
            }
            zoneStart = false;
            continue;
        }
        if (item.Html == Easy.Web.CMS.Zone.ZoneEntity.ZoneEndTag)
        {
            zoneStart = false;
            continue;
        }
        @Html.Raw(item.Html)
    }
}
